import socket

c = socket.socket(socket.AF_INET, socket.SOCK_DGRAM)
address = ('192.168.124.1', 2000)#客户端必须写地址
# 发
# c.sendto(b'hello',address)#要加b，变成字节流
c.sendto('考研上岸'.encode('utf8'), address)  # 服务器的ip和端口

# 收
temp = c.recvfrom(100)
print(temp[0])
print(temp[1])
# temp[0]是data，temp[1]是地址和端口号,所以下面这样写也行
# data,c_addr=c.recvfrom(100)
# print(data)
# print(c_addr)

c.close()
